Skip to content

create new endpoint to retrieve workflow schemas by multiple Content Types#35729

Open
dario-daza wants to merge 12 commits into
mainfrom
35471-task-content-drive-endpoint-to-return-workflow-schemes-for-a-list-of-content-types
Open

create new endpoint to retrieve workflow schemas by multiple Content Types#35729
dario-daza wants to merge 12 commits into
mainfrom
35471-task-content-drive-endpoint-to-return-workflow-schemes-for-a-list-of-content-types

Conversation

@dario-daza
Copy link
Copy Markdown
Member

@dario-daza dario-daza commented May 16, 2026

Proposed Changes

  • Added GET /api/v1/workflow/contenttypes/schemes endpoint (findAllSchemesByContentTypeList) that accepts a comma-separated contentTypeIds query parameter and returns workflow schemes grouped by content type
  • Created AbstractContentTypeWorkflowSchemesView (Immutables) with contentTypeId + contentTypeSchemes fields, and ResponseEntityContentTypeWorkflowSchemesView as the typed response wrapper
  • The endpoint accepts contentTypeIds comma-separated values (?contentTypeIds=id1,id2,id3) rather than repeated params — trims whitespace and filters empty tokens
  • Added integration tests in WorkflowResourceResponseCodeIntegrationTest covering: null input, empty string, whitespace-only tokens, IDs with surrounding whitespace, invalid ID (expects 404), happy path with comma-separated valid IDs, and documented repeated-param limitation
  • Fix and add postman test to test the Workflow Schemas

Additional Info

The endpoint returns a structured List<{contentTypeId, contentTypeSchemes[]}> rather than a flat deduplicated list - this keeps the association between each content type and its schemes intact and lets the frontend handle deduplication if needed.

This PR fixes: #35471

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 16, 2026

Claude finished @dario-daza's task in 4m 53s —— View job


PR Review

Endpoint logic is sound and well-tested. A few items worth a second look:

Worth addressing

  1. N+1 lookup pattern — undermines the "batch" purposeWorkflowResource.java:620-637 runs workflowHelper.findSchemesByContentType(id, user) per ID in a sequential stream(). Each call does contentTypeAPI.find(id) + workflowAPI.findSchemesForContentType(...). With the 100-ID cap that's ~200 round trips for the worst case. The whole reason this endpoint exists (per the PR description) is so the frontend doesn't have to call the single-ID endpoint repeatedly — but the server now does exactly that. Consider a single-pass fetch of content types by ID list and one query for their schemes, or document this is a deliberate first cut.

  2. Asymmetric error handling on a per-ID failure — At WorkflowResource.java:628-633, only NotFoundInDbException is filtered; any other cause inside DotWorkflowException (notably DotSecurityException, which WorkflowHelper.findSchemesByContentType wraps the same way at WorkflowHelper.java:1341-1345) propagates and fails the entire batch. So "unknown ID → silently skip" but "one ID with insufficient permission → whole request errors." That's surprising for a batch endpoint and not documented in the @Operation description. Either decide explicitly (e.g. skip both with a warn, or fail both) or document the split.

  3. Limit check runs on raw tokens before trim/dedupWorkflowResource.java:607 checks rawTokens.length > MAX_CONTENT_TYPE_IDS before whitespace filtering and .distinct(). The javadoc says "checked before deduplication" so it's intentional, but it means ?contentTypeIds=a,b,a,a,... with 50 unique IDs can still 400 if the raw count exceeds 100. The integration test Find_Schemes_By_Content_Type_List_Exceeds_Max_Size_Expect_BadRequest only covers the obvious case. Worth confirming this is the desired UX — most batch endpoints I've seen check after normalization.

  4. Pre-existing truncated UUID (ihoffmann's comment)dotcms-postman/.../documentation/Workflow Resource.json:156, 6168, 9803, 9812 reference d61a59e1a4 which looks truncated vs the full system workflow ID d61a59e1-a49c-46f2-a929-db2b4bfa88b2 used elsewhere. The bad IDs predate this PR (introduced in 8e880cd) but this PR rewrites the file substantially (+619/-985) and re-emits them. Since you're touching the file, worth fixing — at least the lines you re-introduced.

Minor

  1. OpenAPI yaml under-documents the dual formatopenapi.yaml:19544-19548 declares name: contentTypeIds, schema: { type: array, items: { type: string } }. OpenAPI 3 defaults to style: form, explode: true, i.e. repeated params (?contentTypeIds=a&contentTypeIds=b). Implementation also accepts comma-separated values, but generated clients won't emit them. Either add style: form, explode: false (drops the repeated form) or note both in the parameter description (you already do in the Java @Parameter, but the explode behavior of style: form is not what the generator will assume here).

  2. Logger.warn for skipped IDsWorkflowResource.java:640-642. If the frontend ever sends stale/typo'd IDs in normal operation this becomes log noise at warn level. Logger.info or debug is probably fine for a user-supplied-bad-input case.

  3. Test naming nitWorkflowResourceResponseCodeIntegrationTest.java:464 Find_Schemes_By_Content_Type_List_Empty_List actually exercises List.of("") (a list with one empty string). The null/empty list cases are covered separately; this test name reads misleadingly.

Nothing else jumped out

  • View/Immutables + ResponseEntityContentTypeWorkflowSchemesView follow the @Schema rules.
  • Auth path uses InitBuilder with rejectWhenNoUser(true).
  • ExceptionUtil.causedBy does walk the cause chain via getClass().equals(...), so the NotFoundInDbException filter works (subclasses would not match, but the factory throws the exact type at ContentTypeFactoryImpl.java:420).
  • The LayoutChanges.java change is just an unused import removal — fine.

@dario-daza dario-daza marked this pull request as ready for review May 19, 2026 12:52
@dario-daza dario-daza changed the title improve postman workflow tests create new endpoint to retrieve worklow schemas by multiple Content Types May 19, 2026
@dario-daza dario-daza changed the title create new endpoint to retrieve worklow schemas by multiple Content Types create new endpoint to retrieve workflow schemas by multiple Content Types May 19, 2026
Comment thread dotCMS/src/main/java/com/dotcms/rest/api/v1/workflow/WorkflowResource.java Outdated
Comment thread dotCMS/src/main/java/com/dotcms/rest/api/v1/workflow/WorkflowResource.java Outdated
…workflow-schemes-for-a-list-of-content-types
@dario-daza dario-daza enabled auto-merge May 19, 2026 21:27
@dario-daza dario-daza disabled auto-merge May 19, 2026 22:01
@dario-daza dario-daza enabled auto-merge May 19, 2026 22:01
@dario-daza dario-daza added this pull request to the merge queue May 19, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Safe To Rollback Area : Backend PR changes Java/Maven backend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[TASK] Content Drive: endpoint to return workflow schemes for a list of content types

3 participants